<!-- 通知公告明细页面 -->
<template>
  <div class="page">
    <div class="page__bd">
      <article class="weui-article">
        <h1 v-text="item.title"></h1>
        <div class="weui-c-meta">
          <span class="weui-c-nickname">发布时间:</span>
          <em class="weui-c-nickname" v-text="substr(item.publicTime)"></em>
        </div>
        <section v-html="item.detailInfo"></section>
      </article>
    </div>
    <!--BEGIN toast-->
    <div id="infoToast" style="display: none;">
      <div class="weui-mask_transparent"></div>
      <div class="weui-toast">
        <i class="weui-icon-warn weui-icon_toast"></i>
        <p class="weui-toast__content" id="weui-toast__content"></p>
      </div>
    </div>
    <!--end toast-->
  </div>
</template>
<script type="text/javascript">
  import $ from '@/assets/js/jquery-vendor.js'
  import 'jquery.cookie'
  import axios from 'axios'
  import {axiosContentType, apiPath} from '@/assets/js/boss'
  import 'weui'

  export default {
    data() {
      return {
        item: {}
      }
    },
    mounted() {
      let that = this;
      let id = this.$route.query.id;
      axios.get(apiPath + '/api/sys/sysNews/info/' + id
        , null
        , axiosContentType.xWwwFormUrlencoded
      ).then(function (response) {
        const result = response.data;
        if (result.code === 0) {
          that.item = result.data;
        } else {
          that.showMsg(result.message);
        }
      });
    },
    methods: {
      substr(text) {
        if (text === null) {
          return text;
        }
        return ('' + text).substring(0, 16);
      },
      showMsg(msg) {
        let $toast = $('#infoToast');
        if ($toast.css('display') !== 'none') return;
        $('#weui-toast__content').empty().append(msg);
        $toast.fadeIn(100);
        setTimeout(function () {
          $toast.fadeOut(100);
        }, 2000);
      }
    }
  }
</script>
